//广告
$(function(){
	$("img,div.fsbanner_lay").lazyload({effect: "fadeIn", threshold: 200});
})
$(window).scroll();
var swiper = new Swiper('.swiper-container', {
    pagination: '.swiper-pagination',
    nextButton: '.swiper-button-next',
    prevButton: '.swiper-button-prev',
    slidesPerView: 1,
    paginationClickable: true,
    spaceBetween: 0,
    loop: true,
    autoplay: 4800,

    paginationBulletRender: function (index, className) {
        return '<span class="' + className + '"><i></i></span>';
    },
    onSlideChangeStart: function(swiper){
        var _nub=$(".swiper-pagination-bullet").length+1;
        if(swiper.activeIndex/_nub==1){
            $(".swiper-pagination-bullet").eq(0).siblings().find("i").removeAttr("style")
        }else{
            $(".swiper-pagination-bullet").eq(0).find("i").css("width","50px")
            $(".swiper-pagination-bullet").eq(swiper.activeIndex-1).find("i").css("width","50px")
        }
    }
});
$(".swiper-container").hover(function(){
    $(".swiper-button-next, .swiper-button-prev").fadeIn(500);
},function(){
    $(".swiper-button-next, .swiper-button-prev").fadeOut(500);
});
$(".swiper-pagination-bullet").on('click',function(){
    $(".swiper-pagination-bullet").find("i").hide();
    $(".swiper-pagination-bullet").removeAttr("style");
    $(this).css("border-top","2px solid #ffffff");
});
$(".swiper-button-next,.swiper-button-prev").on('click',function(){
    $(".swiper-pagination-bullet").find("i").hide();
    $(".swiper-pagination-bullet").removeAttr("style");
    $(".swiper-pagination-bullet-active").css("border-top","2px solid #ffffff");
});

function SetCookie(name, value) {
    var exp = new Date();
    exp.setTime(exp.getTime() + 30 * 24 * 60 * 60 * 1000); //6天过期
    document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
    return true;
};
//读取cookie
function getCookie(name) {
    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if (arr != null) return unescape(arr[2]); return null;
};

$(".mc_search li").hover(function(){
    $(this).find(".dcancel").delay(100).show();
},function(){
    $(this).find(".dcancel").delay(100).hide();
})

//
$('.dcancel').on('click',function(){
	$(this).parent().find('input').val('');
	$(this).parent().find('i').text('0')
})

//回到顶部
$(function(){
	$(window).on('scroll',function(){
		var st = $(document).scrollTop();
		if( st>100 ){			
			$('#go_top').fadeIn(function(){
				$(this).removeClass('dn');
			});
		}else{
			$('#go_top').fadeOut(function(){
				$(this).addClass('dn');
			});
		}	
	});
	$('#go_top .go').on('click',function(){
		$('html,body').animate({'scrollTop':0},500);
	});
    $(".h_title span,.hd_title span").click(function(){
        var _width=$(this).width()+14;
        var _index=$(this).index();
        var _left=0;
        for(var i=0;i<(_index-1);i++){
            _left+=$(this).parent().find("span").eq(i).width();
            _left+=34;
        }
        $(this).addClass("on").siblings().removeClass("on");
        $(this).parent().find(".xianAnimate").animate({"left":_left,"width":_width},200);
        $(this).parent().parent().find(".h_c").addClass("hide").eq(_index-1).removeClass("hide");
        $(this).parent().parent().find(".hd_c").addClass("hide").eq(_index-1).removeClass("hide");
        $(window).scroll();
    })

});